﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Themes/Default/Views/Shared/Admin.Master" Inherits="System.Web.Mvc.ViewPage<Fashion.Models.User>" %>

<asp:Content ID="Content1" ContentPlaceHolderID="Submenu" runat="server">
<div id="top-panel">
            <div id="panel">
                <ul>
            		<li><a href="../Admin/FindUser" class="search">Find user</a></li>
                </ul>
            </div>
    </div>
</asp:Content>

<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="server">
    <div id="box">
        <h3>Users</h3>
        <div>
            <asp:GridView ID="userList" runat="server" AllowPaging="True" 
                AllowSorting="True" AutoGenerateColumns="False" DataKeyNames="UserID" 
                DataSourceID="listAllUsers">
                <Columns>
                    <asp:HyperLinkField HeaderText="UserID"
                    DataNavigateUrlFields="UserID" SortExpression="UserID"
                    DataNavigateUrlFormatString=
                        "/Admin/UserDetail?uid={0}"
                    DataTextField="UserID">
                    </asp:HyperLinkField>
                    <asp:BoundField DataField="Username" HeaderText="Username" 
                        SortExpression="Username" />
                    <asp:BoundField DataField="Password" HeaderText="Password" 
                        SortExpression="Password" />
                    <asp:BoundField DataField="RoleID" HeaderText="RoleID" 
                        SortExpression="RoleID" />
                    <asp:BoundField DataField="FirstName" HeaderText="FirstName" 
                        SortExpression="FirstName" />
                    <asp:BoundField DataField="LastName" HeaderText="LastName" 
                        SortExpression="LastName" />
                    <asp:BoundField DataField="AddressLine1" HeaderText="AddressLine1" 
                        SortExpression="AddressLine1" />
                    <asp:BoundField DataField="Country" HeaderText="Country" 
                        SortExpression="Country" />
                    <asp:BoundField DataField="Phone" HeaderText="Phone" SortExpression="Phone" />
                    <asp:BoundField DataField="Email" HeaderText="Email" SortExpression="Email" />
                    <asp:BoundField DataField="Points" HeaderText="Points" SortExpression="Points" />
                </Columns>
            </asp:GridView>
            <asp:SqlDataSource ID="listAllUsers" runat="server" 
                ConnectionString="<%$ ConnectionStrings:FashionConnectionString %>" 
                
                SelectCommand="SELECT TOP (20) derivedtbl_1.* FROM (SELECT UserID, Username, Password, RoleID, FirstName, LastName, AddressLine1, Country, Phone, Email, Points FROM Users) AS derivedtbl_1">
            </asp:SqlDataSource>
        </div>
    </div>
        <br />
       <div id="box">
        <h3 id="adduser">Add user</h3>
        <% using (Html.BeginForm()) {%>
        <%: Html.ValidationSummary(true) %>
        
        <fieldset id="account">
            <legend><strong>ACCOUNT INFORMATION</strong></legend>
            
            <div class="editor-field">
                <%: Html.HiddenFor(model => model.UserID)%>
            </div>
            
            <div class="editor-field">
                <%: Html.LabelFor(model => model.Username)%>
                <%: Html.TextBoxFor(model => model.Username, new { style="width:300px" })%>
                <%: Html.ValidationMessageFor(model => model.Username, "Username is invalid") %>
            </div>
            
            <div class="editor-field">
                <%: Html.LabelFor(model => model.Password)%>
                <%: Html.TextBoxFor(model => model.Password, new { style = "width:300px" })%>
                <%: Html.ValidationMessageFor(model => model.Password, "Password is invalid") %>
            </div>

            <div class="editor-field">
                <%: Html.LabelFor(model => model.Email)%>
                <%: Html.TextBoxFor(model => model.Email, new { style="width:300px" })%>
                <%: Html.ValidationMessageFor(model => model.Email, "Email is invalid") %>
            </div>

            <div class="editor-field">
                <%: Html.LabelFor(model => model.RoleID)%>
                <%: Html.TextBoxFor(model => model.RoleID, new { style="width:300px" })%>
                <%: Html.ValidationMessageFor(model => model.RoleID, "RoleID is invalid") %>
            </div>
            <div class="editor-field">
                <%: Html.LabelFor(model => model.Points)%>
                <%: Html.TextBoxFor(model => model.Points, new { style="width:300px" })%>
                <%: Html.ValidationMessageFor(model => model.Points, "Points is invalid") %>
            </div>
    </fieldset>
    <fieldset id="personal">      
        <legend><strong>PERSONAL INFORMATION</strong></legend>      
            <div class="editor-field">
                <%: Html.LabelFor(model => model.FirstName)%>
                <%: Html.TextBoxFor(model => model.FirstName, new { style="width:300px" })%>
                <%: Html.ValidationMessageFor(model => model.FirstName, "Firstname is invalid") %>
            </div>
            
            <div class="editor-field">
                <%: Html.LabelFor(model => model.LastName)%>
                <%: Html.TextBoxFor(model => model.LastName, new { style="width:300px" })%>
                <%: Html.ValidationMessageFor(model => model.LastName, "Lastname is invalid") %>
            </div>
            
            <div class="editor-field">
                <%: Html.LabelFor(model => model.AddressLine1)%>
                <%: Html.TextBoxFor(model => model.AddressLine1, new { style="width:300px" })%>
                <%: Html.ValidationMessageFor(model => model.AddressLine1, "Address is invalid") %>
            </div>
            
            <div class="editor-field">
                <%: Html.HiddenFor(model => model.AddressLine2, new { style="width:300px" })%>
            </div>
            
            <div class="editor-field">
                <%: Html.LabelFor(model => model.City)%>
                <%: Html.TextBoxFor(model => model.City, new { style="width:300px" })%>
                <%: Html.ValidationMessageFor(model => model.City, "City is invalid") %>
            </div>
            
            <div class="editor-field">
                <%: Html.LabelFor(model => model.PostalCode)%>
                <%: Html.TextBoxFor(model => model.PostalCode, new { style="width:300px" })%>
                <%: Html.ValidationMessageFor(model => model.PostalCode, "PostalCode is invalid") %>
            </div>
            
            <div class="editor-field">
                <%: Html.LabelFor(model => model.Country)%>
                <%: Html.TextBoxFor(model => model.Country, new { style = "width:300px" })%>
                <%: Html.ValidationMessageFor(model => model.Country, "Country is invalid") %>
            </div>
            
            <div class="editor-field">
                <%: Html.LabelFor(model => model.Phone)%>
                <%: Html.TextBoxFor(model => model.Phone, new { style="width:300px" })%>
                <%: Html.ValidationMessageFor(model => model.Phone, "Phone is invalid") %>
            </div> 
    </fieldset>
    <% } %>
        <div align="center">
            <input id="button1" type="submit" value="Save" /> 
            <input id="button2" type="reset" />
        </div>
    </div>
</asp:Content>